<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#-- 包含其他文件的内容 -->
    <#include "../common/header.ftl"/>
    <script src="/js/CkeditorBasic/ckeditor/ckeditor.js"></script>
    <script>
        $(function () {
            // 点击查看系统通知
            $(".lookBtn").click(function () {
                var content = $(this).data('content');
                $("#lookModal .modal-body").html(content);

                $("#lookModal").modal("show");
            });

            // 点击发布公告
            $(".inputBtn").click(function () {
                $("#inputModal").modal("show");
            });

            // 高级查询,类型的值一改变就查询
            $("select[name=msgType]").change(function () {
                $("#searchForm").submit();
            });

            // 点击发送按钮
            $(".submitBtn").click(function () {
                var content = ckeditor.getData();
                // 设置到表单的textarea
                $("#editor1").html(content);

                $("#editForm").ajaxSubmit(function (data) {
                    handleResult(data);
                });
            });
        });
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
            <#-- 往数据模型中填充一个属性 -->
            <#assign menu="messageInfo"/>
            <#include "../common/menu.ftl"/>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">系统消息管理</h1>
                </div>
            </div>
            <!-- 高级查询 --->
            <form class="form-inline" id="searchForm" action="/messageInfo/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>通知类型:</label>
                    <select class="form-control" name="msgType">
                        <option value="-1">全部通知</option>
                        <option value="0">系统推送</option>
                        <option value="1">审核通知</option>
                    </select>
                    <script>
                        $("select[name=msgType]").val(${(qo.msgType)!});
                    </script>
                </div>
                <a role="button" class="btn btn-success inputBtn">
                    <span class="glyphicon glyphicon-plus"></span> 发布公告
                </a>
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>编号</th>
                    <th>消息标题</th>
                    <th>消息类型</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>

                <#-- 循环迭代指令 -->
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td>${entity.title}</td>
                        <td>${(entity.msgTypeName)!}</td>
                        <td>${entity.createtime?string('yyyy-MM-dd HH:mm:ss')}</td>
                        <td>
                            <a class="btn btn-info btn-xs lookBtn" data-content='${entity.content}'>
                                <span class="glyphicon glyphicon-pencil"></span> 查看信息内容
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl"/>
        </div>
    </div>
</div>

<#-- 查看内容模态框 -->
<div class="modal fade" id="lookModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">通知内容</h4>
            </div>
            <div class="modal-body">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<#-- 编辑模态框 -->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">发布公告</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/messageInfo/save.do" method="post" id="editForm">

                    <div class="form-group">
                        <label class="col-sm-4 control-label">标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="title">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">通知类型：</label>
                        <div class="col-sm-6">
                            <textarea name="content" id="editor1" rows="10" cols="80"></textarea>
                            <script>
                                var ckeditor = CKEDITOR.replace('editor1');
                            </script>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-4 control-label">通知类型：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="msgType">
                                <option value="0">系统推送</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    <span class="glyphicon glyphicon-off"></span> 关闭
                </button>
                <button type="button" class="btn btn-primary submitBtn">
                    <span class="glyphicon glyphicon-saved"></span> 发送
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

</body>
</html>